﻿#region
using System;
using System.Diagnostics;
using DevExpress.XtraBars;
using DevExpress.XtraEditors;
using Nonsul.Biz;
using Nonsul.CoreModule;
using Nonsul.Data;
using Nonsul.Data.Properties;

#endregion

namespace %Namespace%
{
    public partial class %Entity%ListControl : EntityListControl
    {
        public %Entity%ListControl()
        {
            InitializeComponent();
        }

        #region overriden properties
        private %Entity% FocusedEntity
        {
            get { return (%Entity%) UntypedFocusedEntity; }
        }
        #endregion

        #region overriden methods
        protected override EntityForm CreateEntityForm(UntypedEntity untypedEntity)
        {
            return new %Entity%Form(untypedEntity);
        }

        protected override UntypedEntity CreateNewEntity()
        {
            %Entity% entity = BizRepository.%Entity%.Create(string.Empty, ServerClock.Instance.Today);

            return entity;
        }

        protected override UntypedEntity InsertEntityToDb(UntypedEntity untypedEntity)
        {
            return BizRepository.%Entity%.Insert((%Entity%) untypedEntity);
        }

        protected override string UpdateEntityToDb(UntypedEntity untypedEntity)
        {
            return BizRepository.%Entity%.Update((%Entity%) untypedEntity);
        }

        protected override string DeleteEntityToDb(UntypedEntity untypedEntity)
        {
            return BizRepository.%Entity%.Delete((%Entity%) untypedEntity);
        }
        #endregion

        #region event handlers
        #endregion
    }
}